const express = require('express');
const axios = require('axios');
const router = express.Router();

/**
 * 发送余票监控信息到企业微信
 * 并且开启轮询监控余票 TODO
 */
router.get('/', async (req, res) => {
    const { userid, content, access_token } = req.query

    console.log('aaaa', userid, content)
    const { data } = await axios.post(`https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${access_token}`, {
        "touser": userid,
        "msgtype": "miniprogram_notice",
        "agentid": 1000004,
        "miniprogram_notice": {
            "appid": "wx9057f7ee51912317",
            "page": `pages/index/index?userid=${userid}`,
            ...JSON.parse(content)
        },
    });

    console.log('eeeerr', data)

    return res.json(data)
})


module.exports = router